package com.then.architecture.data.repository;

import android.arch.lifecycle.LiveData;

import com.then.architecture.AppExecutors;
import com.then.architecture.data.api.ApiResponse;
import com.then.architecture.data.dto.Resource;

/**
 * Created by 42524 on 2018/1/9.
 */

public class BaseRepository<T> {

    protected AppExecutors appExecutors;

    protected T remoteService;


    protected BaseRepository(AppExecutors appExecutors,T remoteService){
        this.appExecutors=appExecutors;
        this.remoteService=remoteService;
    }


    protected  <ResultType, RequestType> LiveData<Resource<ResultType>> call(LiveData<ApiResponse<RequestType>> data){
        return new SimpleNetBoundResource<ResultType, RequestType>(appExecutors) {
            protected LiveData<ApiResponse<RequestType>> createCall() {
                return data;
            }
        }.asLiveData();
    }



}
